const req = require.context('./modules', false, /\.js$/)

const install = (Vue) => {
  let api = Vue.prototype.$axios.api || {}
  req.keys().forEach(item => {
    const module = req(item)
    const keys = Object.keys(module)
    keys.forEach(key => {
      api = {
        ...api,
        [key]: module[key]
      }
    })
    Vue.prototype.$axios.api = api
  })
}

export default { install }